﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Acms.AcmsControls;
using System.Text;

/// <summary>
/// Summary description for BaseTemplatePage
/// </summary>
public class BaseTemplatePage : TemplatePage
{
    public BaseTemplatePage()
    {
    }

    protected override void OnInit(EventArgs e)
    {
        if (!IsPostBack)
        {
            if (AcmsContext.CurrentPost != null && (AcmsContext.CurrentPost.Path.ToLower().StartsWith("~/private/") || AcmsContext.CurrentPost.Path.ToLower() == "~/private"))
            {
                if (!Request.IsAuthenticated)
                {
                    StringBuilder url = new StringBuilder();
                    url.Append("~/login.aspx?ReturnUrl=");
                    url.Append(Server.UrlEncode(AcmsContext.CurrentPost.Url));
                    url.Append(Request.QueryString.ToString());
                    Response.Redirect(url.ToString(), true);
                }
            }
        }

    }
}
